<!-- 我的收藏 -->
<template>
  <div class="collect">
    <CollectNavBar></CollectNavBar>
    <van-card
      v-for="(items,id) in mycollects"
      :key="id"
      :price="items.selling_price"
      :desc="`库存: ${items.goods_stock}`"
      :title="items.goods_title"
      :thumb="items.goods_logo"
    >
      <div slot="footer">
        <van-button size="small" type="danger">取消收藏</van-button>
      </div>
    </van-card>
  </div>
</template>
  </div>
</template>

<script>
import CollectNavBar from "./collect-component/CollectNavBar";
export default {
  name: "collect",
  data() {
    return {
      mycollects: []
    };
  },
  methods: {
    mycollect() {
      let user_id = this.$store.state.user_id;
      this.$http({
        method: "post",
        url: "index/web/myCollection",
        data: {
          user_id,
          page: null
        }
      })
        .then(res => {
          console.log(res.data.data);
          this.mycollects = res.data.data;
        })
        .catch(err => {
          console.log(err);
        });
    },
    async cancelCollect(index, row, product_id) {
      let user_id = this.$store.state.user_id;
      //  console.log(user_id, product_id);
      await this.$http({
        method: "post",
        url: "index/web/delCollection",
        data: {
          user_id,
          product_id
        }
      })
        .then(res => {
          console.log(res, "erafa");
          if (res.data.State.Code == 200) {
            this.$Notify({ type: "success", message: "取消成功" });

            this.mycollect();
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    jumpdetails() {
      console.log("查看详情");
    }
  },
  mounted() {
    this.mycollect();
  },
  components: {
    CollectNavBar
  }
};
</script>
<style lang='scss' scoped>
.collect {
  div {
    width: 100%;
    height: 100%;
  }
}
</style>